Skip to content

Strip Common Indentation from BlockString Descriptions #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dackroyd
Copy link
Contributor

@dackroyd dackroyd commented Oct 4, 2019

Fixes #355

@@ -0,0 +1,77 @@
package common
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is adapted from the graphql-js implementation, which is under the MIT license. This will need attribution as per that license, which I assume is preferred via a comment at the top of the file here?

Copy link
Member

@pavelnikolov pavelnikolov Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dackroyd, please add a comment at the top of the file that this was translated from the reference implementation and add a link to the original code. I think that this should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added in the MIT License as a header to the file, (copied from https://github.com/graphql/graphql-js/blob/5eb7c4ded7ceb83ac742149cbe0dae07a8af9a30/LICENSE), along with a comment explaining that the implementation here is derived from that reference implementation.

@dackroyd dackroyd force-pushed the strip-common-indentation-from-blockstring-descriptions branch from 6cc380c to 698f651 Compare October 31, 2019 21:56
Multi-line descriptions need to have their common indentation level
 (which results from indentation of that part of the schema, rather than
 being intentional for the description text) removed to ensure the
 descriptions use the correct value, are formatted correctly etc

This is to meet the condition documented in the GraphQL spec:

https://graphql.github.io/graphql-spec/June2018/#sec-String-Value

> Since block strings represent freeform text often used in indented
>  positions, the string value semantics of a block string excludes
>  uniform indentation and blank initial and trailing lines via
>  BlockStringValue().
@pavelnikolov pavelnikolov merged commit adde0d0 into graph-gophers:master Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BlockStringValues do not strip common indentation
2 participants